package hotel.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import hotel.dao.UsedRoomDao;
import hotel.pojo.RoomDto;
import hotel.service.UseRoomService;

@Controller
public class UseRomeController {
	
	@Autowired
	UseRoomService useRoomService;
	
	@RequestMapping(produces="application/json;charset=UTF-8",
			value="usedRoom",method= {RequestMethod.POST})
	@ResponseBody
	public Map<String,Object> usedRoom(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = new HashMap<String,Object>();
		List<RoomDto> list = useRoomService.UseRomeCondition("1");
		System.out.println("22222");
		if(list == null) {
			map.put("error", "nothing in the system");
		}
		map.put("massage","succeed to find room condition");
		map.put("info",list);
		return map;
	}
	
	@RequestMapping(produces="application/json;charset=UTF-8",
			value="unuseRoom",method= {RequestMethod.POST})
	@ResponseBody
	public Map<String,Object>unuseRoom(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = new HashMap<String,Object>();
		List<RoomDto> list = useRoomService.UseRomeCondition("0");
		if(list == null) {
			map.put("error", "nothing in the system");
		}
		map.put("massage","succeed to find room condition");
		map.put("info",list);
		return map;
	}
	
}
